let userInfoKit = {}
userInfoKit.userLocalStorageKey = "user-info"
userInfoKit.appid = "100009"
/**
 * 保存用户信息到localStorage
 * @param resp
 */
userInfoKit.save = function (resp) {
  let userInfo = {
    "account": "", // 账号
    "uid": "", // 用户id
    "appid": "",
    "token": "",
    "avatar": "", // 用户头像
    "mobile": "", // 用户手机号
    "realName": "", // 用户真实姓名
    "idCard": "", // 用户身份证号
    "email": "", // 邮箱
    "qq": "", // qq号
    "wechat": "", // 微信号
    "levels": "",
    "isTourist": "", // 是否为游客：1:是，0：否
    "deviceId": "", // 设备号
    "hasPwd": "" // 是否有密码
  }
  $.extend(userInfo, resp.data.userInfo)
  window.localStorage.removeItem(this.userLocalStorageKey)
  window.localStorage.setItem(this.userLocalStorageKey, JSON.stringify(userInfo))
}
/**
 * 生成设备id
 * @returns {string}
 */
userInfoKit.getDeviceId = function () {
  var s = []
  var hexDigits = "0123456789abcdef"
  for (var i = 0; i < 35; i++) {
    s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1)
  }
  s[14] = "4"
  s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1)
  s[8] = s[13] = s[18] = s[23]
  return s.join("") + "_h5sdk"
}
/**
 * 从localStorage中获取用户信息
 * @returns {string}
 */
userInfoKit.getUserInfo = function () {
  let userInfoString = window.localStorage.getItem(this.userLocalStorageKey)
  if (userInfoString != null && userInfoString != "") {
    return JSON.parse(userInfoString)
  }
}

/**
 * 判断是否登录
 * @returns {boolean}
 */
userInfoKit.isLogin = function () {
  return this.getUserInfo() == null ? false : true
}

/**
 * 是否游客登录　
 * @returns {boolean}
 */
userInfoKit.isTourist = function () {
   // 真实登录
   if (this.isLogin() && this.getUserInfo().isTourist !== "1"){
      return false
   // 否则都是游客登录
   } else {
     return true
   }
}

//rem 适配
!function (e, i) {
var t = e.documentElement, n = navigator.userAgent.match(/iphone|ipod|ipad/gi), a = n ? Math.min(i.devicePixelRatio, 3) : 1, m = "orientationchange" in window ? "orientationchange" : "resize";
    t.dataset.dpr = a;
    for (var d, l, c = !1, o = e.getElementsByTagName("meta"), r = 0; r < o.length; r++)l = o[r], "viewport" == l.name && (c = !0, d = l);
    if (c)d.content = "width=device-width,initial-scale=1.0,maximum-scale=1.0, minimum-scale=1.0,user-scalable=no"; else {
        var o = e.createElement("meta");
        o.name = "viewport", o.content = "width=device-width,initial-scale=1.0,maximum-scale=1.0, minimum-scale=1.0,user-scalable=no", t.firstElementChild.appendChild(o)
    }
    var s = function () {
        var e = t.clientWidth;
        e / a > 750 && (e = 750 * a), window.remScale = e / 750, t.style.fontSize = 200 * (e / 750) + "px"
    };
    s(), e.addEventListener && i.addEventListener(m, s, !1)
}(document, window);

var commen = {};
//获取浏览器类型
commen.getBrowserType = function () {
  var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
  var isOpera = userAgent.indexOf("Opera") > -1;
  //判断是否Opera浏览器
  if (isOpera) {
    return "Opera"
  };
  //判断是否Firefox浏览器
  if (userAgent.indexOf("Firefox") > -1) {
    return "FF";
  }
  //判断是否chorme浏览器
  if (userAgent.indexOf("Chrome") > -1){
    return "Chrome";
  }
  //判断是否Safari浏览器
  if (userAgent.indexOf("Safari") > -1) {
    return "Safari";
  }
  //判断是否IE浏览器
  if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) {
    return "IE";
  }
  //判断是否Edge浏览器
  if (userAgent.indexOf("Trident") > -1) {
    return "Edge";
  }
}
commen.gameName = "青云诀"
commen.gameIcon = "static/img/game-logo.png"
commen.gameUrl = "http://d.fire2333.com/xdpt/xyzhushou/index/2095/200042"